Use Perf To Do Profiling

Meow King January 08, 2024 Updated: January 08, 2024 #profiling #perf #linux

Use rust project for example:

build the project

cargo build # debug mode can see all the functions 
cargo build --release # when in release mode, `--call-graph dwarf` can see some of the functions

record the data

--call-graph dwarf works best for my experience. EDIT: 2024-01-09 reason see Debugging support in the Rust compiler

perf record --call-graph dwarf ./target/debug/part2

view the data

  1. perf built-in viewer:
perf report
  1. use firefox profiler Firefox profiler enables you to also view the flamegraph, stack chart too.
perf script > /tmp/part2.perf

then drag-drop the file into the website.

  1. use hotspot (haven't tried).